import format from '@dfeidao/atom-web/dt/format';
import get from '@dfeidao/atom-web/global/get';
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import show from '@dfeidao/atom-web/ui/show';
import p001 from './p001';
import set from '@dfeidao/atom-web/local/set';
export default async function a001(fd: IFeidaoAiBrowserComponent,no: string) {

	// todo
	const dis = fd.data.node.querySelector<HTMLDivElement>('[data-id="dis"]');
	set_node_cls(dis, 'display-n', false);
	show(fd.data.node);


	set(fd,'no',no)
	const res = await nodejs<{
		d1: Array<{
			meeting_status: string, meeting_name: string, meeting_host: string, start_time: number, finish_time: number,
			meeting_address: string, conference_theme: string
		}>,
		d2: Array<{ annex_name: string, annex_file: string }>,
		d3: Array<{ conference_reso_no: string, conference_reso_content: string }>
	}>('meeting-management/zj-000002/s001', {
		meeting_no: no
	});

	// const conference_reso_no = res.d3[0].conference_reso_no;
	const arr4 = String();
	for (let i = 0; i < res.d3.length; i++) {
		// tslint:disable-next-line:no-unused-expression
		arr4 === res.d3[i].conference_reso_no;
	}
	const res1 = await nodejs<Array<{ meeting_minutes_annex: string, annex_name: string }>>('meeting-management/zj-000002/s002', {
		meeting_no: no,
		conference_reso_no: arr4
	});
	const arr = Array();
	// 将数据保存到一个数组中
	if (res.d1.length > 0) {
		arr[0] = {
			meeting_status: res.d1[0].meeting_status,
			meeting_name: res.d1[0].meeting_name,
			meeting_host: res.d1[0].meeting_host,
			start_time: [res.d1[0].start_time],
			finish_time: [res.d1[0].finish_time],
			meeting_address: res.d1[0].meeting_address,
			conference_theme: res.d1[0].conference_theme,
			annex_name: '',
			annex_file: '',
			conference_reso_no: '',
			conference_reso_content: '',
			meeting_minutes_annex: '',
			annex_name1: ''
		};
		// tslint:disable-next-line: no-shadowed-variable
		const arr1 = arr.map((n) => {
			return { ...n, start_time: format(n.start_time[0], 2), finish_time: format(n.finish_time[0], 2) };
		});
		render(fd, arr1, p001, 'p001', 'inner');
	}
	if (res.d1.length > 0 && res.d3.length > 0) {
		arr[0] = {
			meeting_status: res.d1[0].meeting_status,
			meeting_name: res.d1[0].meeting_name,
			meeting_host: res.d1[0].meeting_host,
			start_time: [res.d1[0].start_time],
			finish_time: [res.d1[0].finish_time],
			meeting_address: res.d1[0].meeting_address,
			conference_theme: res.d1[0].conference_theme,
			annex_name: '',
			annex_file: '',
			conference_reso_no: res.d3[0].conference_reso_no,
			conference_reso_content: res.d3[0].conference_reso_content,
			meeting_minutes_annex: '',
			annex_name1: ''
		};
		// tslint:disable-next-line:no-shadowed-variable
		const arr1 = arr.map((n) => {
			return { ...n, start_time: format(n.start_time[0], 2), finish_time: format(n.finish_time[0], 2) };
		});
		render(fd, arr1, p001, 'p001', 'inner');
	}
	if (res.d2.length > 0 && res.d1.length > 0) {
		arr[0] = {
			meeting_status: res.d1[0].meeting_status,
			meeting_name: res.d1[0].meeting_name,
			meeting_host: res.d1[0].meeting_host,
			start_time: [res.d1[0].start_time],
			finish_time: [res.d1[0].finish_time],
			meeting_address: res.d1[0].meeting_address,
			conference_theme: res.d1[0].conference_theme,
			annex_name: res.d2[0].annex_name,
			annex_file: res.d2[0].annex_file,
			conference_reso_no: '',
			conference_reso_content: '',
			meeting_minutes_annex: '',
			annex_name1: ''
		};
		// tslint:disable-next-line:no-shadowed-variable
		const arr1 = arr.map((n) => {
			return { ...n, start_time: format(n.start_time[0], 2), finish_time: format(n.finish_time[0], 2) };
		});
		render(fd, arr1, p001, 'p001', 'inner');
	}
	if (res.d1.length > 0 && res1.length > 0) {
		arr[0] = {
			meeting_status: res.d1[0].meeting_status,
			meeting_name: res.d1[0].meeting_name,
			meeting_host: res.d1[0].meeting_host,
			start_time: [res.d1[0].start_time],
			finish_time: [res.d1[0].finish_time],
			meeting_address: res.d1[0].meeting_address,
			conference_theme: res.d1[0].conference_theme,
			annex_name: '',
			annex_file: '',
			conference_reso_no: '',
			conference_reso_content: '',
			meeting_minutes_annex: res1[0].meeting_minutes_annex,
			annex_name1: res1[0].annex_name
		};
		// tslint:disable-next-line:no-shadowed-variable
		const arr1 = arr.map((n) => {
			return { ...n, start_time: format(n.start_time[0], 2), finish_time: format(n.finish_time[0], 2) };
		});
		render(fd, arr1, p001, 'p001', 'inner');
	}
	if (res.d3.length > 0 && res.d2.length > 0 && res.d1.length > 0) {
		arr[0] = {
			meeting_status: res.d1[0].meeting_status,
			meeting_name: res.d1[0].meeting_name,
			meeting_host: res.d1[0].meeting_host,
			start_time: [res.d1[0].start_time],
			finish_time: [res.d1[0].finish_time],
			meeting_address: res.d1[0].meeting_address,
			conference_theme: res.d1[0].conference_theme,
			annex_name: res.d2[0].annex_name,
			annex_file: res.d2[0].annex_file,
			conference_reso_no: res.d3[0].conference_reso_no,
			conference_reso_content: res.d3[0].conference_reso_content,
			meeting_minutes_annex: '',
			annex_name1: ''
		};
		// tslint:disable-next-line:no-shadowed-variable
		const arr1 = arr.map((n) => {
			return { ...n, start_time: format(n.start_time[0], 2), finish_time: format(n.finish_time[0], 2) };
		});
		render(fd, arr1, p001, 'p001', 'inner');
	}
	if (res1.length > 0 && res.d3.length > 0 && res.d2.length > 0 && res.d1.length > 0) {
		arr[0] = {
			meeting_status: res.d1[0].meeting_status,
			meeting_name: res.d1[0].meeting_name,
			meeting_host: res.d1[0].meeting_host,
			start_time: [res.d1[0].start_time],
			finish_time: [res.d1[0].finish_time],
			meeting_address: res.d1[0].meeting_address,
			conference_theme: res.d1[0].conference_theme,
			annex_name: res.d2[0].annex_name,
			annex_file: res.d2[0].annex_file,
			conference_reso_no: res.d3[0].conference_reso_no,
			conference_reso_content: res.d3[0].conference_reso_content,
			meeting_minutes_annex: res1[0].meeting_minutes_annex,
			annex_name1: res1[0].annex_name
		};
		// tslint:disable-next-line:no-shadowed-variable
		const arr1 = arr.map((n) => {
			return { ...n, start_time: format(n.start_time[0], 2), finish_time: format(n.finish_time[0], 2) };
		});
		render(fd, arr1, p001, 'p001', 'inner');
	}

}
